#define _CRT_SECURE_NO_WARNINGS 1

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */

int DoubleNode(struct ListNode* node)
{
    if (node->next == NULL)
    {
        int a = node->val * 2;
        node->val = a % 10;
        return a / 10;
    }
    int a = node->val * 2 + DoubleNode(node->next);
    node->val = a % 10;
    return a / 10;
}

struct ListNode* doubleIt(struct ListNode* head) {
    int a = DoubleNode(head);

    if (a != 0)
    {
        struct ListNode* newNode = (struct ListNode*)malloc(sizeof(struct ListNode));
        newNode->val = a;
        newNode->next = head;
        head = newNode;
    }

    return head;
}